<?php

/**
 * personne form base class.
 *
 * @method personne getObject() Returns the current form's model object
 *
 * @package    forumCDE
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BasepersonneForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'code'            => new sfWidgetFormInputText(),
      'name'            => new sfWidgetFormInputText(),
      'nom'             => new sfWidgetFormInputText(),
      'prenom'          => new sfWidgetFormInputText(),
      'initiales'       => new sfWidgetFormInputText(),
      'password'        => new sfWidgetFormInputText(),
      'email'           => new sfWidgetFormInputText(),
      'tel'             => new sfWidgetFormInputText(),
      'tel2'            => new sfWidgetFormInputText(),
      'photo'           => new sfWidgetFormInputText(),
      'entite_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('entite'), 'add_empty' => true)),
      'dateentree'      => new sfWidgetFormDate(),
      'datenaissance'   => new sfWidgetFormDate(),
      'fonction_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('fonction'), 'add_empty' => true)),
      'sexe'            => new sfWidgetFormInputText(),
      'codevehicule_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('codevehicule'), 'add_empty' => true)),
      'administrator'   => new sfWidgetFormInputCheckbox(),
      'algorithm'       => new sfWidgetFormInputText(),
      'salt'            => new sfWidgetFormInputText(),
      'activeStatus'    => new sfWidgetFormInputText(),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'code'            => new sfValidatorString(array('max_length' => 20)),
      'name'            => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'nom'             => new sfValidatorString(array('max_length' => 50)),
      'prenom'          => new sfValidatorString(array('max_length' => 50)),
      'initiales'       => new sfValidatorString(array('max_length' => 15, 'required' => false)),
      'password'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'email'           => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'tel'             => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'tel2'            => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'photo'           => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'entite_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('entite'), 'required' => false)),
      'dateentree'      => new sfValidatorDate(array('required' => false)),
      'datenaissance'   => new sfValidatorDate(array('required' => false)),
      'fonction_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('fonction'), 'required' => false)),
      'sexe'            => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'codevehicule_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('codevehicule'), 'required' => false)),
      'administrator'   => new sfValidatorBoolean(array('required' => false)),
      'algorithm'       => new sfValidatorString(array('max_length' => 128, 'required' => false)),
      'salt'            => new sfValidatorString(array('max_length' => 128, 'required' => false)),
      'activeStatus'    => new sfValidatorInteger(),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'personne', 'column' => array('code')))
    );

    $this->widgetSchema->setNameFormat('personne[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'personne';
  }

}
